﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using VonaJobs.DAL.DAO;

namespace VonaJobs.DAL.Gatway
{
    public class AdGateway:DBGateway
    {
        public string SaveAd(Ad ad)
        {
            try
            {
                ConnectionObj.Open();
                CommandObj.CommandText =
                string.Format("insert into tblAd values(@ImagePath)");
                CommandObj.Parameters.Clear();
                CommandObj.Parameters.Add("@ImagePath", SqlDbType.VarChar).Value = ad.ImagePath;                
                CommandObj.ExecuteNonQuery();
                return "Ad Save Successfully";
            }
            catch (Exception)
            {
                throw new Exception("Message Not Send, Server Error !");
            }
            finally
            {
                if (ConnectionObj != null && ConnectionObj.State == ConnectionState.Open)
                {
                    ConnectionObj.Close();
                }
                
            }
        }
    }
}